import matplotlib.pyplot as plt
import random

class My_Line:
    def __init__(self,x_list,y_list,
                 title="The title of the graph"
                 ,legend=""):
        self.x_list = x_list
        self.y_list = y_list
        self.title = title
        self.legend = legend
        self.rotation = 30
        self.linestyle = None

    def show_line(self):
        l1, = plt.plot(self.x_list,self.y_list,linestyle=self.linestyle,color="black")
        plt.scatter(self.x_list,self.y_list,edgecolors="red",c="red",s=30)
        """怎么添加图例和标注，我在研究研究。。。。。"""
        # plt.legend(loc="lower right",title=self.legend,fontsize=10,
        #            handles=[l1,],)
        # ax = plt.gca()
        # ax.annotate(f"{self.annotates[0]} {round(self.y_list[0],2)}",
        #     xy=(self.x_list[0],self.y_list[0]),
        #             ha = "center",va = "top",
        #             fontsize=18,color="purple")

        plt.xticks(rotation=self.rotation,ha="center")
        plt.grid(True,"both",axis="y",linestyle="dashed")
        plt.title(self.title,font="fantasy",fontsize=20)
        # plt.ylabel(self.y_label,font="fantasy",fontsize=15)

        name = rf"D:\python\line{random.randint(1, 1000)}.jpg"
        plt.savefig(name)
        # plt.show()
        return name

class Summary_Page:
    def __init__(self,file_obj,title="数据分析页面"):
        self.file = file_obj
        self.title = title
    def create_page(self,images=[]):
        self.file.write(f"<!DOCTYPE html>\n"
                        f"<html lang=\"en\">\n"
                        f"\t<head>\n"
                        f"\t\t<meta charset=\"UTF-8\">\n"
                        f"\t\t<title>{self.title}</title>\n"
                        f"\t</head>\n"
                        f"\t<body>\n")
        for i in images:
            self.file.write(f"\t\t<img src=\"{i}\">\n")

        self.file.write("\t</body>\n"
                        "</html>")

if __name__ == '__main__':
    pass


















